package com.java.annotation.fruit;

import java.io.Serializable;
import java.lang.reflect.Field;

/**
 * 注解处理器
 * @author wangning
 * @create 2021-11-23 16:45
 */
public class FruitInfoUtil {
	public static void getFruitInfo(Class<?> clazz) {
		String strFruitProvider = "供应商信息：";
		Field[] fields = clazz.getDeclaredFields();//通过反射获取处理注解
		for (Field field : fields) {
			if(field.isAnnotationPresent(FruitProvider.class)) {
				FruitProvider fruitProvider = (FruitProvider) field.getAnnotation(FruitProvider.class);
				//注解信息的处理地方
				System.out.println(strFruitProvider);
				strFruitProvider = "供应商编号：" + fruitProvider.id() + " 供应商名称：" + fruitProvider.name()
						+ " 供应商地址：" + fruitProvider.address();
				System.out.println(strFruitProvider);

			}
		}
	}
}
